load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "statistics",
    srcs = [
        "analyze.go",
        "analyze_jobs.go",
        "builder.go",
        "cmsketch.go",
        "cmsketch_util.go",
        "column.go",
        "debugtrace.go",
        "estimate.go",
        "fmsketch.go",
        "histogram.go",
        "index.go",
        "interact_with_storage.go",
        "merge_worker.go",
        "row_sampler.go",
        "sample.go",
        "scalar.go",
        "table.go",
    ],
    importpath = "github.com/pingcap/tidb/statistics",
    visibility = ["//visibility:public"],
    deps = [
        "//config",
        "//expression",
        "//kv",
        "//parser/ast",
        "//parser/charset",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//planner/util/debugtrace",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//tablecodec",
        "//types",
        "//util/chunk",
        "//util/codec",
        "//util/collate",
        "//util/dbterror",
        "//util/fastrand",
        "//util/hack",
        "//util/logutil",
        "//util/mathutil",
        "//util/memory",
        "//util/ranger",
        "//util/sqlexec",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_twmb_murmur3//:murmur3",
        "@org_golang_x_exp//maps",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "statistics_test",
    timeout = "short",
    srcs = [
        "cmsketch_bench_test.go",
        "cmsketch_test.go",
        "fmsketch_test.go",
        "histogram_test.go",
        "integration_test.go",
        "main_test.go",
        "sample_test.go",
        "scalar_test.go",
        "statistics_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":statistics"],
    flaky = True,
    shard_count = 41,
    deps = [
        "//config",
        "//parser/ast",
        "//parser/model",
        "//parser/mysql",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//statistics/handle",
        "//testkit",
        "//testkit/testdata",
        "//testkit/testmain",
        "//testkit/testsetup",
        "//types",
        "//util/chunk",
        "//util/codec",
        "//util/collate",
        "//util/mock",
        "//util/ranger",
        "//util/sqlexec",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@com_github_tiancaiamao_gp//:gp",
        "@org_uber_go_goleak//:goleak",
    ],
)
